#ifndef TEXT_TEXTHTMLMESSAGERENDERER_H
#define TEXT_TEXTHTMLMESSAGERENDERER_H

#include <QObject>


namespace Converse {
class AbstractMessage;
}

namespace Text {

class HtmlMessageRenderer : public QObject
{
    Q_OBJECT
public:
    explicit HtmlMessageRenderer(QObject *parent = 0);

public:
    const QString &htmlDocument();
    void appendMessage(const Converse::AbstractMessage *message);
    void insertMessage(int position, const Converse::AbstractMessage *message);
    void setMessage(const QString &text);
    void clear();
    void update();

private:
    QString templateDocument() const;
    QString templateHeader() const;
    QString templateTable() const;
    QString templateMessageCell() const;
    QString templateTimeCell() const;
    QString htmlMessageRow(const QString &message, const QString &time);
    QString htmlMessageRow(const QString &message, qint64 time);
    void refreshTableMessage();
    void refreshPlainMessage();
    void refresh();

private:
    QString m_htmlDocument;
    QString m_plainMessage;
    QList<const Converse::AbstractMessage *> m_messageList;
    bool m_isTable;
};

} // namespace Text

#endif // TEXT_TEXTHTMLMESSAGERENDERER_H
